<template>
    <div style="margin: 0 10px 0 10px">
        <div style="margin: 10px">
            标题: <Input v-model="dataFilter.title" size="small" placeholder="" style="width: 120px" />
            <Button type="primary" shape="circle" icon="ios-search" style="margin-left: 15px" @click="loadData"></Button>
        </div>
        <!--<div style="margin: 10px">
            <Button type="primary" @click="handleAdd">新增</Button>
        </div>-->
        <Table :data="tableData"  :columns="columns"  border highlight-row  :loading="loading">
            <template slot-scope="{ row, index }" slot="action">
                <Button type="primary" size="small" style="margin-right: 5px" @click="handleView(row,index)">查看</Button>
                <Button type="primary" size="small" style="margin-right: 5px" @click="handleAudit(row,index)">审核</Button>
                <Button type="error" size="small" @click="handleRemove(row,index)">删除</Button>
            </template>
        </Table>
        <div style="margin: 25px;overflow: hidden">
            <div style="float: right;">
                <Page :total="total" :current="dataFilter.current" :page-size="dataFilter.size"
                      show-sizer
                      @on-change="changePage" @on-page-size-change="changeSize" :page-size-opts="[10,20,50,100]"></Page>
            </div>
        </div>
        <Modal  v-model="auditModal"  title="审核"  width="380" :styles="{top: '60px'}" footer-hide>
            <MyAudit ref="auditModal" @saveSucces="loadData">
            </MyAudit>
        </Modal>
        <Modal  v-model="viewModal"  title="查看"  width="780" :styles="{top: '60px'}" footer-hide>
            <MyView ref="viewModal" @saveSucces="loadData">
            </MyView>
        </Modal>
    </div>
</template>
<script>
    import MyAudit from './Audit';
    import MyView from './View';
    import Base from '@/components/table/BaseList';
    import dictUtils from '@/common/dictUtils';
    export default {
        components:{
            MyAudit,MyView
        },
        extends:Base,
        data () {
            return {
                columns: [
                    { type: 'index', width: 60, align: 'center'},
                    { title: '标题', key: 'title'},
                    /*{ title: '求助内容详情', key: 'content'},*/
                    { title: '求助用户名', key: 'helpUserName'},
                    { title: '审核结果', key: 'auditResult'},
                    { title: '提交时间', key: 'createTime'},
                    { title: '操作', key: 'action',slot: 'action', width: 200, align: 'center'}
                ],
                auditModal:false,
                dataFilter:{
                    auditResult:"01"
                }
            }
        },
        mounted(){
            this.loadData();
        },
        methods: {
            handleAudit(row){
                //审核功能
                this.auditModal=true;
                this.$refs.auditModal.loadDataById(row.id);
            },handleView(row){
                //查看功能
                this.viewModal=true;
                this.$refs.viewModal.loadDataById(row.id);
            },
            loadData(){
                this.auditModal=false;
                //获取列表数据
                this.baseLoadData('/api/help/list',()=>{
                    dictUtils.decodeList('audit_type',this.tableData,"auditResult")
                });
            },handleAdd(){
                //新增功能
                this.auditModal=true;
                this.$refs.auditModal.loadDataById(null);
            },handleRemove(row){
                //删除
                this.baseRemove('/api/help/delete',{id:row.id});
            }
        }
    }
</script>
